<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Document</title>
  </head>
  <body>
    <script>
      var arr = ['red', 'green', 'blue', 'pink'];
      var str = arr[0];
      var sep = '|';
      for (var i = 1; i < arr.length; i++) {
        str += sep + arr[i];
      }
      console.log(str);	// 输出结果：red|green|blue|pink
    </script>
  </body>
</html>